package com.csu.cphone.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.csu.common.exception.WebException;
import com.csu.cphone.pojo.StorePojo;
import com.csu.cphone.service.StoreService;
import com.csu.cphone.vo.ResultVo;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;

/**
 * @项目名称：cphone
 * @类名称：StoreController
 * @类描述：
 * @创建人：Tangc
 * @创建时间：2017年9月12日 下午2:10:07
 * @company:
 */
@Controller
@RequestMapping("/storeinfo")
@Api(value = "base", description = "基础信息")
public class StoreController
{
    @Autowired
    private StoreService storeService;

    @ResponseBody
    @ApiOperation(value = "门店信息", notes = "返回附近的门店信息列表")
    @RequestMapping(value = "nearlist", method = RequestMethod.POST, produces = { "application/json; charset=utf-8" })
    public ResultVo<List<StorePojo>> login(HttpServletRequest request,
            @ApiParam(value = "经度") @RequestParam(value = "lng", required = true) double lng,
            @ApiParam(value = "纬度") @RequestParam(value = "lat", required = true) double lat) throws WebException
    {
        ResultVo<List<StorePojo>> result = new ResultVo<List<StorePojo>>();
        List<StorePojo> storeList = storeService.getNearlistStore(lng, lat);

        result.setData(storeList);
        return result;

    }
}
